<template>
  <div id="app">
    <router-view/>
    <theme-picker/>
    <div v-if="showWatermark" v-watermark="{watermarkText:watermarkText}"/>
  </div>
</template>

<script>
import ThemePicker from "@/components/ThemePicker";

export default {
  name: "App",
  components: {ThemePicker},
  metaInfo() {
    return {
      title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
      titleTemplate: title => {
        return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
      }
    }
  },
  data() {
    return {
      watermarkText: null,
      showWatermark: false
    }
  },
  watch: {
    '$store.state.user.name': function(newName) {
      if (newName) {
        this.watermarkText = newName;
        this.showWatermark = true;
      }
    }
  }
};
</script>
<style scoped>
#app .theme-picker {
  display: none;
}
</style>
